<?php

declare(strict_types=1);

namespace App\Cola\Model;

use Hyperf\Database\Model\SoftDeletes;
use Mine\MineModel;

/**
 * @property int $id
 * @property int $user_id 用户id
 * @property int $pay_source 交易来源:1=个人记账,2=支付宝,3=微信,4=云闪付,5=抖音,6=拼多多,7=美团
 * @property string $pay_time
 * @property int $trade_cate_id 交易分类
 * @property string $counterparty 交易对方
 * @property string $counterparty_account 交易对方账号
 * @property string $goods 商品
 * @property int $cash_flow 收支类型:1=收入,2=支出,3=不计入支出
 * @property string $money 交易金额
 * @property string $payment_method 收/付款方式
 * @property string $trade_status 交易状态
 * @property string $trade_sn 交易单号
 * @property string $trade_store_sn 交易商户单号
 * @property string $remark 备注
 * @property \Carbon\Carbon $created_at 创建时间
 * @property \Carbon\Carbon $updated_at 修改时间
 * @property string $deleted_at 删除时间
 */
class ColaBill extends MineModel
{
    use SoftDeletes;

    public bool $incrementing = false;
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'cola_bill';

    const PAY_SOURCE_USER = 1;

    const  PAY_SOURCE_ALIPAY = 2;

    const PAY_SOURCE_WECHAT = 3;

    const PAY_SOURCE_YUNSHANFU = 4;

    const PAY_SOURCE_TIKTOK = 5;

    const PAY_SOURCE_PINDUODUO = 6;

    const PAY_SOURCE_MEITUAN = 7;


    /**
     * The attributes that are mass assignable.
     */
    protected array $guarded = [];


    public function tradeCate()
    {
        return $this->hasOne(ColaTradeCate::class);
    }

    /**
     * 多对多关联账单
     * */
    public function ledgers()
    {
        return $this->belongsToMany(ColaLedger::class);
    }
}
